package annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Collection;

/**
 * @author kxd
 * 扩展注解的支持
 * ElementType.TYPE_USE,
 * ElementType.TYPE_PARAMETER是两个新添加的用于描述
 * 适当的注解上下文的元素类型
 */
public class Annotations {

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
    public @interface NonEmpty {

    }

    public static class Holder<@NonEmpty T> extends @NonEmpty Object {
        public void method() throws @NonEmpty Exception {

        }

        public static void main(String[] args) {
            final Holder<String> holder = new @NonEmpty Holder<String>();
            @NonEmpty
            Collection<@NonEmpty String> strings = new ArrayList<>();

        }
    }
}
